<?php
session_start();
/**
 * @author Minh Luan
 * @copyright 2012
 */
$pid = $_GET["n"];
$q = $_GET["q"];

if(isset($_SESSION['cart'])){
    //Cart existed
    $cart = $_SESSION['cart'];
    if(isset($cart[$pid]))
    {
        //Product in cart
        $qty = $q;
    }
    else
    {
        //Product not in cart
        $qty=1;
    }
    if($qty > 0){
        $cart[$pid] = $qty;    
    }else{
        unset($cart[$pid]);
    }
    
    $_SESSION['cart'] = $cart;
}
echo "<script>location.href='../pc/cart.php';</script>";

?>